package ModelLayer;
import java.util.ArrayList;

public class Person
{
    // instance variables
    private String id;
    private String name;
    private String address;
    private String postalCode;
    private String city;
    private String phone;
    private ArrayList<Loan> loans;
    
    public Person(String id, String name, String address, String postalCode, String city, String phone)
    {
        this.id = id;
        this.name = name;
        this.address = address;
        this.postalCode = postalCode;
        this.city = city;
        this.phone = phone;
        loans=new ArrayList<Loan>();
    }
    
    public void setId(String Id)
    {
        this.id = Id;
    }
    
    public void setName(String Name)
    {
        this.name = Name;
    }
    
    public void setAddress(String Address)
    {
        this.address = Address;
    }
    
    public void setPostalCode(String PostalCode)
    {
        this.postalCode = PostalCode;
    }
    
    public void setCity(String City)
    {
        this.city = City;
    }
    
    public void setPhone(String Phone)
    {
        this.phone = Phone;
    }
    
    public String getId()
    {
        return id;
    }
    
    public String getName()
    {
        return name;
    }
    
    public String getAddress()
    {
        return address;
    }
    
    public String getPostalCode()
    {
        return postalCode;
    }
    
    public String getCity()
    {
        return city;
    }
    
    public String getPhone()
    {
        return phone;
    }
    
    public void addLoan(Loan loan)
    {
        loans.add(loan);
    }
    
    public ArrayList<Loan> getLoanList()
    {
         return loans;
    }
    
    public void deleteLoan(Loan loan)
    {
        loans.remove(loan);
    }
    
    public String toString() //returns string with data about a person
    {
         String s="ID="+getId()+'\n'+"Name="+getName()+'\n'+"Address="+getAddress()+'\n'+"PostalCode="+getPostalCode()+'\n';
         s+="City="+getCity()+'\n'+"Phone="+getPhone()+'\n';
         if(loans.size()==0)
         {
             s+="This person has no loans";
            }
         for (Loan loan1: loans)
         {
             s+="Loan ID="+ loan1.getId()+'\n' + "Period=" + loan1.getPeriod() +'\n';
         }
         return s;
    }
}
